#include<stdio.h>
int main()
{
	int danjia;
	int zongjia;
	int shuliang;
    printf("请输入购买的数量和单价：");
	scanf("%d %d",&shuliang,&danjia);
	while(shuliang>50){
		printf("货物只有50个，请重新输入");
		scanf("%d",&shuliang);
		while(danjia>10){
			printf("单价最高为10元，请重新输入：");
			scanf("%d",&danjia);
		}
	}
	zongjia=shuliang*danjia;
	int qian;
	int zongtouru=0;
	printf("请投入1元或2元或5元:");
	scanf("%d",&qian);
	while(qian!=1&&qian!=2&&qian!=5){
		printf("只能投入1元或2元或5元，请重新投入:");
		scanf("%d",&qian);
	}
		zongtouru=zongtouru+qian;
	while(zongtouru<zongjia){
		printf("请继续投入1元或2元或5元:");
		scanf("%d",&qian);
		while(qian!=1&&qian!=2&&qian!=5){
			printf("只能投入1元或2元或5元，请重新投入:");
			scanf("%d",&qian);
		}
		zongtouru=zongtouru+qian;
	}
	if(zongtouru>zongjia){
		printf("购买完毕，找您%d元",zongtouru-zongjia);
	}
	else{
		printf("购买完毕");
	}
	
	return 0;
}
